<cpanel include="../../config.php">

<?

/***************************************************************************
 *                                 subdomain_stats.php
 *                            -------------------
 *   Begin                : Thursday, April 16, 2005
 *   Copyright            : (C) 2005 Point and Code
 *   Domain               : http://www.pointandcode.com/
 *   Email                : support@pointandcode.com
 *   Version              : 1.0.1
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

$html_root_path = '../../';
include $root_path.'common.php';
$page_title = $lang['subdomain_stats'];
include $root_path.'page_header.php';


$template->set_filenames(array(
	'body' => $root_path.$template_path.'stats/subdomain_stats.tpl')
);






$is_analog_installed = <<<EOF
<cpanelif !$CONF{'skipanalog'} $CPDATA{'FEATURE-ANALOG'}><cpanelfeature analog>test</cpanelfeature></cpanelif>
EOF;

if (!empty($is_analog_installed)) {
	$template->assign_block_vars('switch_analog', array());
}

$analog_junk = <<<EOFpacman
<cpanel Stats="printsubanalinks()">
EOFpacman;

$analog_junk = explode('<br>', $analog_junk);

$array_of_analog = array();
$i=0;

foreach($analog_junk as $row) {
	$temp = explode('<a href="', $row);
	$temp2 = explode('"', $temp[1]);
	$array_of_analog[$i]['url'] = str_replace("analog.html", "analog.php", $temp2[0]);

	// Get the path
	$temp2 = explode('">', $temp[1]);
	$temp3 = explode('</a>', $temp2[1]);
	$array_of_analog[$i]['domain'] = $temp3[0];

	$i++;
};

foreach ($array_of_analog as $row) {
	if (!empty($row['url'])) {
		$template->assign_block_vars('switch_analog.analogrow', array(
			'URL' => $row['url'],
			'NAME' => $row['domain'],
		));
	};
};





$is_webalizer_installed = <<<EOF
<cpanelif !$CONF{'skipwebalizer'} $CPDATA{'FEATURE-WEBALIZER'}><cpanelfeature webalizer>test</cpanelfeature></cpanelif>
EOF;

if (!empty($is_webalizer_installed)) {
	$template->assign_block_vars('switch_webalizer', array());
}

$webalizer_junk = <<<EOFpacman
<cpanel Stats="printsubwebalinks()">
EOFpacman;

$webalizer_junk = explode('<br>', $webalizer_junk);

$array_of_webalizer = array();
$i=0;

foreach($webalizer_junk as $row) {
	$temp = explode('<a href="', $row);
	$temp2 = explode('"', $temp[1]);
	$array_of_webalizer[$i]['url'] = $temp2[0];

	// Get the path
	$temp2 = explode('">', $temp[1]);
	$temp3 = explode('</a>', $temp2[1]);
	$array_of_webalizer[$i]['domain'] = $temp3[0];

	$i++;
};

foreach ($array_of_webalizer as $row) {
	if (!empty($row['url'])) {
		$template->assign_block_vars('switch_webalizer.webalizerrow', array(
			'URL' => $row['url'],
			'NAME' => $row['domain'],
		));
	};
};




$is_awstats_installed = <<<EOF
<cpanelif !$CONF{'skipawstats'} $CPDATA{'FEATURE-AWSTATS'}><cpanelfeature awstats>test</cpanelfeature></cpanelif>
EOF;

if (!empty($is_awstats_installed)) {
	$template->assign_block_vars('switch_awstats', array());
}

$awstats_junk = <<<EOFpacman
<cpanel Stats="printsubawstatslinks()">
EOFpacman;

$awstats_junk = explode('<br>', $awstats_junk);

$array_of_awstats = array();
$i=0;

foreach($awstats_junk as $row) {
	$temp = explode('<a href="', $row);
	$temp2 = explode('"', $temp[1]);
	$array_of_awstats[$i]['url'] = $temp2[0];

	// Get the path
	$temp2 = explode('">', $temp[1]);
	$temp3 = explode('</a>', $temp2[1]);
	$array_of_awstats[$i]['domain'] = $temp3[0];

	$i++;
};

foreach ($array_of_awstats as $row) {
	if (!empty($row['url'])) {
		$template->assign_block_vars('switch_awstats.awstatsrow', array(
			'URL' => $row['url'],
			'NAME' => $row['domain'],
		));
	};
};

$template->assign_vars(array(
	'L_SUBDOMAIN_STATS' => $lang['subdomain_stats'],
	
	'L_ANALOG' => $lang['analog'],
	'L_AWSTATS' => $lang['awstats'],
	'L_WEBALIZER' => $lang['webalizer'],
));


//
// Woohoo! All done!
//
$template->pparse('body');

include $root_path.'page_tail.php';


?>